
var id ="";

var stateFormatter = function(value,row,index){

    if(value==1){
        return ['<a href="javascript:void(0)">正常</a>'].join('');
    }else if(value==0){
        return ['<a href="javascript:void(0)" style="color:red">维修</a>'].join();
    }
}

var guzhangFormatter=function(value,row,index){
    return ['<a href="javascript:void(0)" class="chuli">故障处理</a>'].join('');
}


window.guzhangEvents={
    'click .chuli':function(e,value,row,index){
        showModel("guzhangChuli");
        id=value;
    }
}

bindClick("#sucessChuLi",function(){
    comment.showOperationTips("你确定处理吗？",function(){
        $.post($().AbsUrlParse("/web/inspection/sucessChuLi"),{id:id},function(data){
            closeModel("guzhangChuli");
        });
    })

})


$.post($().AbsUrlParse("/web/motoroom/allPositionSelect"),{

},function(data){

    var datas = data.res.data;
    var selects = "<select class='form-control' name='wName'><option value=''>请输入位置</option>";
    for(var i=0;i<datas.length;i++){
        var val = datas[i].wName;
        selects+= "<option name="+val+">"+val+"</option>"
    }
    selects+="</select>"
    $("#postionSelect").html(selects);
});


bindClick("#xjSearBtn",function(){
    //得到查询的信息
    var xjtimeSear = $("input[name=xjtimeSear]").val();
    var xjstart = "", xjend = "";
    if (xjtimeSear != null) {
        xjstart = xjtimeSear.split(" - ")[0];
        xjend = xjtimeSear.split(" - ")[1];
    }

    var wName = $("select[name=wName]").val();
    var xjcycleSear = $("select[name=xjcycleSear]").val();
    var xjmachnameSear = $("input[name=xjmachnameSear]").val();

    var url=$().AbsUrlParse("/web/inspection/inspectionjlQuery?xjstart="+xjstart+"&xjend="+xjend+"&wName="+wName+"&xjcycleSear="+xjcycleSear+"&xjmachnameSear="+xjmachnameSear);
    $("#table").bootstrapTable("refresh",{url:url});

});


//初始化页面的时候运行该函数
$(function () {
    initDateRange();
});

function initDateRange() {
    $(".rangedate").daterangepicker({
        "autoApply": true,
        "locale": {
            "applyLabel": "确定",
            "cancelLabel": "取消",
            "fromLabel": "开始",
            "toLabel": "结束",
            "customRangeLabel": "Custom",
            "weekLabel": "周",
            "daysOfWeek": [
                "日",
                "一",
                "二",
                "三",
                "四",
                "五",
                "六"
            ],
            "monthNames": [
                "1月",
                "2月",
                "3月",
                "4月",
                "5月",
                "6月",
                "7月",
                "8月",
                "9月",
                "10月",
                "11月",
                "12月"
            ],
            "cancelLabel": '清空',
            "opens": "right"
        },
        "format": "YYYY-MM-DD"
    }).on('cancel.daterangepicker', function (ev, picker) {
        $(this).val('');
    });


}